<?
include "includes/common_public_inc.php";
$bid=getParam("bid","");
if ($bid>0)
{
	$sql_banner = "SELECT goto_url FROM $banner_tbl WHERE bid=$bid";	
	$res_banner = q($sql_banner);
	$row=mysql_fetch_array($res_banner);
	$goto_url = $row["goto_url"];	
	echo "<html>";
	if ($goto_url)
	{			
		q("update $banner_tbl set clicks = 0 where bid=$bid AND clicks IS NULL");
		q("update $banner_tbl set clicks = clicks + 1,run_for_clicks = run_for_clicks - 1 where bid=$bid");		
		redirect("$goto_url");
	}
}
?>
</html>